<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/tabs.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript">
    var listType="icon";
    var currentHouseId="";
	var currentCoalitionId= "";

</script>
</head>
<body>
<script type="text/javascript">
  function setListType(listTypeO){
      listType=listTypeO;
     var form = document.getElementById("roomSearchForm");

       if(listType=='list'){
          form.action="${ctx}/house_houseAction.do?method=housesList";
       }
       else{
           form.action="${ctx}/house_houseAction.do?method=housesIconList";
       }
  }

   function ChangeList(url){

     document.getElementById("connTabPanel").src=url;
  }

  function onKeyResearch(){
    if(event.keyCode==13){
    queryRoom();
    }
  }

  function queryRoom(){
      currentHouseId='';
	   var form = document.getElementById("roomSearchForm");

         if(listType=='list'){
            form.action="${ctx}/house_houseAction.do?method=housesList";
         }
         else{
             form.action="${ctx}/house_houseAction.do?method=housesIconList";
         }
		 form.submit();

	}

	function refleshFrame(){
	   if(listType=='icon'){
      document.frames["connTabPanel"].document.location.href="${ctx}/house_houseAction.do?method=housesIconList&buildingId=${buildingId}";
	   }else if(listType=='list'){
         document.frames["connTabPanel"].document.location.href="${ctx}/house_houseAction.do?method=housesList&buildingId=${buildingId}";
	   } else if(listType=='buildingDetail'){
         document.frames["connTabPanel"].document.location.href="${ctx}/house_buildingAction.do?method=initBuildingDetail&buildingId=${buildingId}";
	   }

	   currentHouseId="";

	}

    function openHouseAdd(){
      var url = "${ctx}/house_houseAction.do?method=initialHouseAdd&buildingId=${buildingId}&projectId=${projectId}";

		top.windowOpen(url, "HouseAdd", "增加房间", 465, 750,true,"HouseAdd");
    }

    function openHouseEdit(){
    if(currentHouseId == "")
	  {
	   Alert('请选择一条记录后再修改!');
	   return false;
	  }

        var url = "${ctx}/house_houseAction.do?method=initialHouseEdit&projectId=${projectId}&keyword="+currentHouseId;
		top.windowOpen(url, "HouseEdit", "修改房间", 465, 750,true,"HouseEdit");
    }

    function deleteHouse(){
    if(currentHouseId == "")
	  {
	   Alert('请选择一条记录后再删除!');
	   return false;
	  }
      AskConfirm("你确定删除该记录吗?","mainFrame","${ctx}/house_houseAction.do?method=deleteHouse&keyword="+currentHouseId);

    }

    function openBuidingEdit(){

    parent.currentIsEdit="edit";
     var url = "${ctx}/house_buildingAction.do?method=initBuildingEdit&hasMoreProject="+parent.hasMoreProject+"&areaId=${areaId}&buildingId=${buildingId}";
		top.windowOpen(url, "buidingEdit", "修改楼栋", 550, 800,true,"buidingEdit");
    }

    function setCurrentHouseId(houseId){
         currentHouseId = houseId;

    }

    function setCurrentCoalitionId(coalitionId)
    {
    	currentCoalitionId = coalitionId;
    }

    function openCoalitionHouse()
    {
    	var url = "${ctx}/house_coalitionHouseAction.do?method=initCoalitionHouseAdd&&projectId=${projectId}";
		top.windowOpen(url, "houseChooses", "新增房间合并", 400, 450,true,"houseChooses");
    }

    function editCoalitionHouse()
    {
   		if(currentCoalitionId != "")
   		{
	   	    var url = "${ctx}/house_coalitionHouseAction.do?method=initCoalitionHouseEdit&coalitionHouseId="+currentCoalitionId;
			top.windowOpen(url, "houseChooses", "修改房间合并", 400, 450,true,"houseChooses");
		}
		else
		{
			Alert("该房间无相关管理房不能修改!");
		}
   }

    function deleteCoalitionHouse()
    {
   		if(currentCoalitionId != "")
   		{
	   	    var url = "${ctx}/house_coalitionHouseAction.do?method=initCoalitionHouseDelete&coalitionHouseId="+currentCoalitionId;
			top.windowOpen(url, "coalitionHouseDelete", "解除房间合并", 190, 350,true,"coalitionHouseDelete");
		}
		else
		{
			Alert("该房间无相关管理房不能解除!");
		}
    }


     function getBuildingName(){
    return '${buildingName}';
    }

    function openAddMeter(){
    var url = "${ctx}/house_meterAction.do?method=initAddHouseMeter&areaId=${areaId}";
    top.windowOpen(url, "addMeter", "新增房间走表", 500, 800,true,"addMeter");

    }

    function openChangeHouseState(){

    if(currentHouseId == "")
	  {
	   Alert('请选择一条记录!');
	   return false;
	  }

        var url = "${ctx}/house_houseAction.do?method=initHouseStatePage&keyword="+currentHouseId;
		//top.windowOpen(url, "HouseStateEdit", "修改房间状态", 220, 450,true,"HouseStateEdit");
         common_submit("","noAskWindow",url,'修改房间状态',220,450);

    }

    function openEditMeter(){
    if(currentHouseId == "")
	  {
	   Alert('请选择一条记录!');
	   return false;
	  }

        var url = "${ctx}/house_meterAction.do?method=initMeterMaintenanceList&houseId="+currentHouseId;
		top.windowOpen(url, "HouseMeterEdit", "走表维护", 360, 800,true,"HouseMeterEdits");
    }

</script>
<div id="researchRoom" style="display:none">
<table border="0" cellspacing="0" cellpadding="0"  width="100%" class="bg_search" id="search01" >
          <tr>
            <td>
            <table border="0" align="left" cellpadding="0" cellspacing="1" >
            <form name="roomSearchForm" id="roomSearchForm" action="${ctx}/house_houseAction.do?method=housesIconList" method="post" target="connTabPanel">
            <input type="hidden" name="buildingId" value="${buildingId}"/>
              <tr>
                <td class="td_search">&nbsp;&nbsp;房号： </td>
                <td class="td_search"><input name="houseNumber" autocomplete="off" type="text" size="15" height="16" class="inputtext" onKeyPress="onKeyResearch();"></td>
                <td><table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td><table border="0" cellpadding="0" cellspacing="0" onClick="search_result(this)">
                          <tr>
                            <td class="buttonOffLeft" id="btn1_11"></td>
                            <td class="buttonOffMiddle" id="btn1_12" onMouseOver="btn_change_over(1)" onMouseOut="btn_change_out(1)" onblur="btn_change(1)" onClick="queryRoom();" onfocus="this.blur()"><img src="${ctx}/images/ico_lookup.gif" alt="" border="0" align="absmiddle"> 查
                              询</td>
                            <td class="buttonOffRight" id="btn1_13"></td>
                          </tr>
                      </table></td>
                    </tr></form>
                </table>
                </td>
                <td class="td_search">&nbsp;</td>
              </tr>
            </table></td>
          </tr>
      </table>
</div>

<div id="roomFunction" style="display:none">
<table border="0" align="right" cellpadding="0" cellspacing="0" id="ico1">
<tr>
<pms:AuthTag authName="house_houseAction.do?method=initialHouseAdd">
         <td class="toolbarico"><a href="#"  onClick="openHouseAdd();return false;"onFocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="新建房屋"/>&nbsp;</a></td>
</pms:AuthTag>
<pms:AuthTag authName="house_houseAction.do?method=initialHouseEdit">
           <td  class="toolbarico" onClick=""><a href="#"  onClick="openHouseEdit();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" alt="修改房屋资料" width="16" height="16" border="0" align="absbottom" /></a></td>
</pms:AuthTag>
<pms:AuthTag authName="house_houseAction.do?method=deleteHouse">
           <td class="toolbarico"><a href="#" onClick="deleteHouse();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="删除" width="16" height="16" border="0" align="absbottom"></a></td>
</pms:AuthTag>
<pms:AuthTag authName="house_coalitionHouseAction.do?method=initCoalitionHouseAdd">
           <td class="toolbar_line">|</td>
           <td class="toolbarico"><a href="#"  onclick="openCoalitionHouse();return false;" onfocus="this.blur()"><img src="${ctx}/images/house_hb.gif" border="0" align="absbottom" alt="新增合并管理"/>&nbsp;新增合并管理</a></td>
</pms:AuthTag>
<pms:AuthTag authName="house_meterAction.do?method=initAddHouseMeter">
           <td class="toolbar_line">|</td>
           <td class="toolbarico"><a href="#"  onclick="openAddMeter();return false;" onfocus="this.blur()"><img src="${ctx}/images/ico_biao_add.gif" border="0" align="absbottom" alt="新增走表"/>&nbsp;新增走表</a></td>
</pms:AuthTag>
           <td class="toolbar_line">|</td>
           <td  class="toolbarico"><a href="#"  onClick="setListType('list');ChangeList('${ctx}/house_houseAction.do?method=housesList&buildingId=${buildingId}');return false;" onFocus="this.blur()"> <img src="${ctx}/images/ico_fc_wz.gif" border="0" align="absbottom" alt="查看列表"/></a></td>
           <td  class="toolbarico"><a href="#"  onClick="setListType('icon');ChangeList('${ctx}/house_houseAction.do?method=housesIconList&buildingId=${buildingId}');return false;" onFocus="this.blur()"> <img src="${ctx}/images/ico_fc_tx.gif" border="0" align="absbottom" alt="查看图示"/></a></td>
 </tr>
 </table>
</div>

<div id="buidingRightFunction" style="display:none">
<table border="0" align="right" cellpadding="0" cellspacing="0" id="ico3" >
                <tr>
                <pms:AuthTag authName="house_buildingAction.do?method=initBuildingEdit">
                  <td class="toolbarico"> <a href="#"  onClick="openBuidingEdit();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="修改楼栋"/></a></td>
                </tr>
                </pms:AuthTag>
              </table>
</div>

<pms:tabPanel panelId="con_tabPanel"
            iframeId="connTabPanel"
            defaultHeight="400px"
            barWidthLeft="50%"
            barWidthRight="50%">
<pms:tab tabId="houseList"
        caption="房间列表"
        baseUrl="${ctx}/house_houseAction.do?method=housesIconList&buildingId=${buildingId}"
        topDiv="researchRoom"
        rightDiv="roomFunction"
        beforeFunction="setListType('icon')"/>

 <pms:tab tabId="buidingMessage"
        caption="楼栋资料"
        baseUrl="${ctx}/house_buildingAction.do?method=initBuildingDetail&buildingId=${buildingId}"
        rightDiv="buidingRightFunction"
        beforeFunction="setListType('buildingDetail')"/>


</pms:tabPanel>


</body>

<script type="text/javascript">
document.roomSearchForm.houseNumber.focus();
</script>
</html>